package plugin.demo.shardingsphere.seata.mappers;

import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

/**
 * @Author: Qiao Hang
 * @CreateDate: 2021/4/20 下午5:00
 * @UpdateDate:
 * @Description:
 */
@Mapper
public interface TestClsMapper {

    @Select("select * from `test`.test_cls")
    List<Map> getAll();

    @Insert("insert into `test`.test_cls(`cls`,`cls_doc`) values (#{row.cls},#{row.clsDoc})")
    int insert(@Param("row") Map<String, String> row);

    @Update("update table `test`.test_cls set cls_doc = #{row.clsDoc} where cls = #{row.cls}")
    int update(@Param("row") Map<String, String> row);

    @Insert("insert into test_order(`uid`,`order_id`) values(#{row.uid},#{row.order_id})")
    int insertOrder(@Param("row") Map<String, Object> row);

    @Insert({"<script>" ,
                "insert into order_item(`uid`,`order_id`,`order_item_id`) values" ,
                    "<foreach collection=\"row.itemIds\" item=\"item_id\" open=\"\" separator=\",\" close=\"\">" ,
                        "(#{row.uid},#{row.order_id},#{item_id})" ,
                    "</foreach>" ,
            "</script>"})
    int insertOrderItem(@Param("row") Map<String, Object> row);
}
